package com.wangzeqi.changliaoba.login;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.wangzeqi.changliaoba.R;

import java.util.ArrayList;

/**
 * Created by dllo on 16/2/29.
 */
public class MainViewPagerAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> data;
    private Context context;
    private ImageView tabImageView;
    private TextView tabTextView;
    private int[] tabImageViewID = new int[]{R.drawable.messege_selector,R.drawable.contacts_selector,R.drawable.live_selector,R.drawable.me_selector,};
    private String[] tabTextViews = new String[]{"消息","通讯录","直播","我"};
    public MainViewPagerAdapter(FragmentManager fm, ArrayList<Fragment> data,Context context) {
        super(fm);
        this.data = data;
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    public View getTabView(int position){
        View view = LayoutInflater.from(context).inflate(R.layout.item_tablayout,null);
        tabImageView = (ImageView) view.findViewById(R.id.tablayout_iv);
        tabTextView = (TextView) view.findViewById(R.id.tablayout_tv);
//        tabImageView.setImageResource(tabImageViewID[position]);
        tabImageView.setBackgroundResource(tabImageViewID[position]);
        tabTextView.setText(tabTextViews[position]);
        return view;
    }
}
